﻿
function displaySubMenu(li) {
    var subMenu = li.getElementsByTagName("ul")[0];
    subMenu.style.display = "block";
}
function hideSubMenu(li) {
    var subMenu = li.getElementsByTagName("ul")[0];
    subMenu.style.display = "none";
}

window.onunload = function() { clearHiddenValue(); $(":checkbox").attr("checked", false); };
function clearHiddenValue() {
    if ($('#ctl00_ContentPlaceHolder1_hidAttachmentId').length != 0) {
        $('#ctl00_ContentPlaceHolder1_hidAttachmentId').val("");
    }
}

window.onerror = function() {
    return true;
}

//验证设置的时间必须要大于当前时间
function checkDateTime(setTimeString) {
    var nowTime = new Date().getDate();
    var checkTime = new Date(setTimeString);

    return checkTime > nowTime;
}

//检测Fck编辑器的内容是否为空，参数值为Fck编辑器的ID
function checkFckValue(fckId) {
    var oEditor = FCKeditorAPI.GetInstance(fckId);
    var checkContent = oEditor.GetXHTML();
    if (checkContent.length == 0) {
        alert("请输入内容！");
        oEditor.Focus();
        return false;
    }
}

//检测TinyMCE编辑器的内容是否为空
function checkTinyMceValue(mceId) {
    if (tinyMCE.get(mceId).getContent() != null && tinyMCE.get(mceId).getContent().length==0) {
        alert("请输入内容！"); 
        return false;
    }
}

//遍历文本控件改变背景颜色
function changeTextControlBgColor() {
    $(":text").css({ background: "#F4F5F6", border: "1px solid #0278B4" });
    $(":text").css("height","20px");
    $(":password").css({ background: "#F4F5F6", border: "1px solid #0278B4" });
    $("textarea").css({ background: "#F4F5F6", border: "1px solid #0278B4" });
    $("select").css({ border: "1px solid #0278B4" });
}

//删除提示函数
function deleteTip() {
    return confirm("确认删除吗？一旦删除不可恢复，请确认！");
}

//Tips提示折叠函数
function tipsFold(infoId, id) {
    if ($('#' + id).css("display") == "none") {
        $('#' + id).css("display", "block");
        $('#' + infoId).text("[收起提示]");
    } else {
        $('#' + id).css("display", "none");
        $('#' + infoId).text("[查看提示]");
    }
}

//全选函数及反选函数
function selectAll() {
    if ($('#dzxBtnSelectAll').val() == "全选") {
        $('#dzxBtnSelectAll').val("取消全选");
        $(":checkbox").attr("checked", true);
    }
    else {
        $('#dzxBtnSelectAll').val("全选");
        $(":checkbox").attr("checked", false);
    }
}

//当全选框为空时，隐藏全选按钮
function hideSelectAllButton() {
    if ($(":checkbox").length == 0 && $('#dzxBtnSelectAll').length == 1) {
        $('#dzxBtnSelectAll').css("display", "none");
    }
}

//触发搜索按钮事件
function enterKey(ent,btnId) {
    ent = (ent) ? ent : (window.event) ? window.event : "";
    if (ent.keyCode == 13) {
        var btn = document.getElementById('ctl00_ContentPlaceHolder1_btnSubmit');
        if (btn != ent.srcElement) {
            btn.focus();
            btn.click();
        }
    }
}
document.onkeydown = enterKey;

$(document).ready(function() {
    changeTextControlBgColor();

    hideSelectAllButton();
});

//检测给定的数字是否在0--100的范围内的浮点数
function checkValueIsFloat(checkValue) {
    if (parseFloat(checkValue)) {
        alert("true");
    }
}